package com.umeng.fb.ui;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.umeng.common.b.g;
import com.umeng.fb.UMFeedbackService;
import com.umeng.fb.b.d;
import com.umeng.fb.util.ActivityStarter;
import com.umeng.fb.util.FeedBackListener;
import com.umeng.fb.util.b;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class SendFeedback extends Activity
{
  static boolean a;
  private static final String b = SendFeedback.class.getName();
  public static ExecutorService executorService;
  private Spinner c;
  private Spinner d;
  private EditText e;
  private TextView f;
  private TextView g;
  private ImageButton h;
  private FeedBackListener i;
  private Map<String, String> j;
  private Map<String, String> k;
  private JSONObject l;

  static
  {
    a = true;
    executorService = Executors.newFixedThreadPool(3);
  }

  private void a()
  {
    this.c = ((Spinner)findViewById(com.umeng.fb.b.c.a(this)));
    this.d = ((Spinner)findViewById(com.umeng.fb.b.c.b(this)));
    this.f = ((TextView)findViewById(com.umeng.fb.b.c.c(this)));
    if (ActivityStarter.useGoBackButton)
    {
      this.g = ((TextView)findViewById(com.umeng.fb.b.c.d(this)));
      this.g.setVisibility(0);
    }
    while (true)
    {
      this.e = ((EditText)findViewById(com.umeng.fb.b.c.e(this)));
      this.h = ((ImageButton)findViewById(com.umeng.fb.b.c.f(this)));
      if (this.c != null)
      {
        ArrayAdapter localArrayAdapter1 = new ArrayAdapter(this, 17367048, getResources().getStringArray(com.umeng.fb.b.a.a(this)));
        localArrayAdapter1.setDropDownViewResource(17367049);
        this.c.setAdapter(localArrayAdapter1);
      }
      if (this.d != null)
      {
        ArrayAdapter localArrayAdapter2 = new ArrayAdapter(this, 17367048, getResources().getStringArray(com.umeng.fb.b.a.b(this)));
        localArrayAdapter2.setDropDownViewResource(17367049);
        this.d.setAdapter(localArrayAdapter2);
      }
      if (this.h != null)
        this.h.setOnClickListener(new e(this));
      b();
      c();
      return;
      this.g = ((TextView)findViewById(com.umeng.fb.b.c.d(this)));
      this.g.setVisibility(4);
    }
  }

  private void b()
  {
    if (this.e != null)
      this.e.setHint(getString(com.umeng.fb.b.e.d(this)));
    if (this.f != null)
      this.f.setText(getString(com.umeng.fb.b.e.e(this)));
    if (this.g == null)
      return;
    this.g.setText(getString(com.umeng.fb.b.e.f(this)));
  }

  private void c()
  {
    String str2;
    String str1 = getIntent().getStringExtra("feedback_id");
    if ((str1 != null) && (this.e != null))
    {
      str2 = getSharedPreferences("feedback", 0).getString(str1, null);
      if (g.c(str2));
    }
    try
    {
      String str3 = new com.umeng.fb.a(new JSONArray(str2).getJSONObject(0)).a();
      this.e.setText(str3);
      com.umeng.fb.util.c.a(this, "feedback", str1);
      if (this.c != null)
      {
        int i2 = d();
        if (i2 != -1)
          this.c.setSelection(i2);
      }
      if (this.d != null)
      {
        int i1 = e();
        if (i1 != -1)
          this.d.setSelection(i1);
      }
      f();
      return;
    }
    catch (Exception localException)
    {
      if (com.umeng.fb.f.h);
      localException.printStackTrace();
    }
  }

  private int d()
  {
    return getSharedPreferences("UmengFb_Nums", 0).getInt("ageGroup", -1);
  }

  private int e()
  {
    return getSharedPreferences("UmengFb_Nums", 0).getInt("sex", -1);
  }

  private void f()
  {
    while (true)
    {
      try
      {
        SharedPreferences localSharedPreferences = getSharedPreferences("UmengFb_Nums", 0);
        String str1 = localSharedPreferences.getString("OtherAttrContext", "");
        String str2 = localSharedPreferences.getString("OtherAttrRemark", "");
        if ((str1 != null) && (str1.length() > 0))
        {
          this.j = getMap(new JSONObject(str1).getJSONObject("Json_OtherAttrContact"));
          if ((str2 == null) || (str2.length() <= 0))
            break label139;
          this.k = getMap(new JSONObject(str2).getJSONObject("Json_OtherAttrRemark"));
          if (this.i == null)
            return;
          this.i.onResetFB(this, this.j, this.k);
          return;
        }
        this.j = null;
      }
      catch (JSONException localJSONException)
      {
        localJSONException.printStackTrace();
        return;
      }
      label139: this.k = null;
    }
  }

  public static JSONObject getJSON(Map<String, String> paramMap)
  {
    Iterator localIterator = paramMap.entrySet().iterator();
    JSONObject localJSONObject = new JSONObject();
    while (true)
      try
      {
        if (!(localIterator.hasNext()))
          return localJSONObject;
        Map.Entry localEntry = (Map.Entry)localIterator.next();
        localJSONObject.put((String)localEntry.getKey(), localEntry.getValue().toString());
      }
      catch (Exception localException)
      {
        System.out.println(localException.getMessage());
      }
    return localJSONObject;
  }

  public static Map<String, String> getMap(JSONObject paramJSONObject)
  {
    try
    {
      Iterator localIterator = paramJSONObject.keys();
      HashMap localHashMap = new HashMap();
      if (!(localIterator.hasNext()))
        return localHashMap;
      String str = (String)localIterator.next();
      localHashMap.put(str, paramJSONObject.get(str).toString());
    }
    catch (JSONException localJSONException)
    {
      localJSONException.printStackTrace();
    }
    return null;
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    requestWindowFeature(1);
    setContentView(d.a(this));
    setFBListener(UMFeedbackService.fbListener);
    a();
    if (this.f != null)
    {
      this.f.setOnClickListener(new b(null));
      if (this.e != null)
        ((InputMethodManager)getSystemService("input_method")).toggleSoftInput(2, 0);
    }
    if (this.g == null)
      return;
    this.g.setOnClickListener(new a(null));
    ((InputMethodManager)getSystemService("input_method")).toggleSoftInput(2, 0);
  }

  protected void onPause()
  {
    try
    {
      ((InputMethodManager)getSystemService("input_method")).hideSoftInputFromWindow(this.e.getWindowToken(), 0);
      super.onPause();
      return;
    }
    catch (Exception localException)
    {
      Log.e(b, localException.getMessage());
    }
  }

  public void setFBListener(FeedBackListener paramFeedBackListener)
  {
    this.i = paramFeedBackListener;
  }

  private class a
    implements View.OnClickListener
  {
    public void onClick(View paramView)
    {
      SendFeedback.this.finish();
      if (ActivityStarter.lastContext == null)
        return;
      ((Activity)ActivityStarter.lastContext).finish();
    }
  }

  private class b
    implements View.OnClickListener
  {
    public void onClick(View paramView)
    {
      int i = -1;
      if (SendFeedback.a(SendFeedback.this) != null);
      for (String str = SendFeedback.a(SendFeedback.this).getText().toString(); ; str = null)
      {
        if (g.c(str))
        {
          Toast.makeText(SendFeedback.this, SendFeedback.this.getString(com.umeng.fb.b.e.a(SendFeedback.this)), 0).show();
          return;
        }
        if (str.length() > 140)
        {
          Toast.makeText(SendFeedback.this, SendFeedback.this.getString(com.umeng.fb.b.e.b(SendFeedback.this)), 0).show();
          return;
        }
        if (SendFeedback.b(SendFeedback.this) != null);
        for (int j = SendFeedback.b(SendFeedback.this).getSelectedItemPosition(); ; j = i)
        {
          JSONObject localJSONObject1;
          JSONObject localJSONObject2;
          if (SendFeedback.c(SendFeedback.this) != null)
            i = SendFeedback.c(SendFeedback.this).getSelectedItemPosition();
          if (SendFeedback.d(SendFeedback.this) != null)
          {
            SendFeedback.d(SendFeedback.this).onSubmitFB(SendFeedback.this);
            SendFeedback.a(SendFeedback.this, ActivityStarter.contactMap);
            SendFeedback.b(SendFeedback.this, ActivityStarter.remarkMap);
            localJSONObject1 = new JSONObject();
            localJSONObject2 = new JSONObject();
            if (SendFeedback.e(SendFeedback.this) == null)
              break label651;
          }
          for (JSONObject localJSONObject3 = SendFeedback.getJSON(SendFeedback.e(SendFeedback.this)); ; localJSONObject3 = null)
          {
            JSONObject localJSONObject4;
            if (SendFeedback.f(SendFeedback.this) != null)
              localJSONObject4 = SendFeedback.getJSON(SendFeedback.f(SendFeedback.this));
            while (true)
            {
              if (localJSONObject3 != null);
              try
              {
                localJSONObject1.put("Json_OtherAttrContact", localJSONObject3);
                if (localJSONObject4 != null)
                  localJSONObject2.put("Json_OtherAttrRemark", localJSONObject4);
                label278: SharedPreferences.Editor localEditor2 = SendFeedback.this.getSharedPreferences("UmengFb_Nums", 0).edit();
                localEditor2.putInt("ageGroup", j);
                localEditor2.putInt("sex", i);
                if ((localJSONObject1 != null) && (localJSONObject1.length() > 0))
                  localEditor2.putString("OtherAttrContext", localJSONObject1.toString());
                if ((localJSONObject2 != null) && (localJSONObject2.length() > 0))
                  localEditor2.putString("OtherAttrRemark", localJSONObject2.toString());
                localEditor2.commit();
                while (true)
                {
                  try
                  {
                    SendFeedback.a(SendFeedback.this, b.a(SendFeedback.this, str, j, i, localJSONObject3, localJSONObject4));
                    com.umeng.fb.util.c.c(SendFeedback.this, SendFeedback.g(SendFeedback.this));
                    com.umeng.fb.a.f localf = new com.umeng.fb.a.f(SendFeedback.g(SendFeedback.this), SendFeedback.this);
                    SendFeedback.executorService.submit(localf);
                    Intent localIntent = new Intent(SendFeedback.this, FeedbackConversations.class).setFlags(131072);
                    SendFeedback.this.startActivity(localIntent);
                    ((InputMethodManager)SendFeedback.this.getSystemService("input_method")).hideSoftInputFromWindow(SendFeedback.a(SendFeedback.this).getWindowToken(), 0);
                    SendFeedback.this.finish();
                    return;
                  }
                  catch (Exception localException3)
                  {
                    if (com.umeng.fb.f.h)
                      localException3.printStackTrace();
                    com.umeng.fb.util.c.d(SendFeedback.this, SendFeedback.g(SendFeedback.this));
                    return;
                  }
                  SharedPreferences.Editor localEditor1 = SendFeedback.this.getSharedPreferences("UmengFb_Nums", 0).edit();
                  localEditor1.putInt("ageGroup", j);
                  localEditor1.putInt("sex", i);
                  localEditor1.commit();
                  try
                  {
                    SendFeedback.a(SendFeedback.this, b.a(SendFeedback.this, str, j, i, null, null));
                  }
                  catch (Exception localException1)
                  {
                    if (com.umeng.fb.f.h)
                      localException1.printStackTrace();
                    com.umeng.fb.util.c.d(SendFeedback.this, SendFeedback.g(SendFeedback.this));
                    label651: return;
                  }
                }
              }
              catch (Exception localException2)
              {
                break label278:
                localJSONObject4 = null;
              }
            }
          }
        }
      }
    }
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     com.umeng.fb.ui.SendFeedback
 * JD-Core Version:    0.5.2
 */